package com.czjtxy.extraTerm.controller.jobmodule;

import com.czjtxy.extraTerm.entity.DO.Tjob;
import com.czjtxy.extraTerm.server.JobService;
import com.czjtxy.extraTerm.serverImpl.JobServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * @program: staff-house
 * @author: MingYi
 * @create: 2021/07/02 18:40
 */
@WebServlet(name = "JobGetOneServlet", value = "/JobGetOneServlet")
public class JobGetOneServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        int uid = 0;
        if (id != null && !"".equals(id)) {
            uid = Integer.parseInt(id);
        }
        JobService jobService = new JobServiceImpl();
        Tjob tjob = null;
        try {
            tjob = jobService.getOne(uid);
            req.setAttribute("tjob", tjob);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        req.getRequestDispatcher("job/showUpdateJob.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
